package ProOF.apl.problems.real.functions;

import ProOF.com.LinkerParameters;
import java.lang.Math;
/**
 *
 * @author Lucas
 */
public class RealFuncH6 extends aRealFunction{

	private double a[][] = {{10, 3, 17, 3.5, 1.7, 8},{0.05, 10, 17, 0.1, 8, 14},
			{3, 3.5, 1.7, 10, 17, 8},{17, 8, 0.05, 10, 0.1, 14}};
	private double p[][] = {{0.1312, 0.1696, 0.5569, 0.0124, 0.8283, 0.5886},
							{0.2329, 0.4135, 0.8307, 0.3736, 0.1004, 0.9991},
							{0.2348, 0.1451, 0.3522, 0.2883, 0.3047, 0.665},
							{0.4047, 0.8828, 0.8732, 0.5743, 0.1091, 0.0381}};
	private double c[] = {1, 1.2, 3, 3.2};
	
	
	@Override
	public void parameters(LinkerParameters link) throws Exception {

	}
	
	@Override
	public int dimension() {
		return 6;
	}
	
	@Override
	public double min( int i ) {
		return -0;
	}
	
	@Override
	public double max( int i ) {
		return 1;
	}

	@Override
	public double f(double[] x) throws Exception {
		check(x);
		
		double infSum = 0, supSum = 0;
		for (int i = 0; i < 4; i++) {
			infSum = 0;
			for (int j = 0; j < 6; j++) {
				infSum += a[i][j]*Math.pow((x[j] - p[i][j]),2);
			}
			supSum += c[i]*Math.exp(-infSum);
		}
		return -supSum;
	}

	@Override
	public String name() {
		return "H6";
	}

	@Override
	public String description() {
		return "Hartman 6 Problem";
	}	
}
